package com.ruoyi.gaokao.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.gaokao.mapper.GkCandidateRegistrationMapper;
import com.ruoyi.gaokao.domain.GkCandidateRegistration;
import com.ruoyi.gaokao.service.IGkCandidateRegistrationService;

/**
 * 考生报名信息Service业务层处理
 * 
 * @author xiaosong
 * @date 2025-07-07
 */
@Service
public class GkCandidateRegistrationServiceImpl implements IGkCandidateRegistrationService 
{
    @Autowired
    private GkCandidateRegistrationMapper gkCandidateRegistrationMapper;

    /**
     * 查询考生报名信息
     * 
     * @param idNumber 考生报名信息主键
     * @return 考生报名信息
     */
    @Override
    public GkCandidateRegistration selectGkCandidateRegistrationByIdNumber(String idNumber)
    {
        return gkCandidateRegistrationMapper.selectGkCandidateRegistrationByIdNumber(idNumber);
    }

    @Override
    public int upsertGkCandidateRegistration(GkCandidateRegistration registration) {
        // 根据身份证号查询已有的记录
        GkCandidateRegistration existing = gkCandidateRegistrationMapper.selectGkCandidateRegistrationByIdNumber(registration.getIdNumber());
        if (existing != null) {
            //更新
            return gkCandidateRegistrationMapper.updateGkCandidateRegistration(registration);
        }else {
            // 新增
            return gkCandidateRegistrationMapper.insertGkCandidateRegistration(registration);
        }
    }


    /**
     * 查询考生报名信息列表
     * 
     * @param gkCandidateRegistration 考生报名信息
     * @return 考生报名信息
     */
    @Override
    public List<GkCandidateRegistration> selectGkCandidateRegistrationList(GkCandidateRegistration gkCandidateRegistration)
    {
        return gkCandidateRegistrationMapper.selectGkCandidateRegistrationList(gkCandidateRegistration);
    }

    /**
     * 新增考生报名信息
     * 
     * @param gkCandidateRegistration 考生报名信息
     * @return 结果
     */
    @Override
    public int insertGkCandidateRegistration(GkCandidateRegistration gkCandidateRegistration)
    {
        return gkCandidateRegistrationMapper.insertGkCandidateRegistration(gkCandidateRegistration);
    }

    /**
     * 修改考生报名信息
     * 
     * @param gkCandidateRegistration 考生报名信息
     * @return 结果
     */
    @Override
    public int updateGkCandidateRegistration(GkCandidateRegistration gkCandidateRegistration)
    {
        return gkCandidateRegistrationMapper.updateGkCandidateRegistration(gkCandidateRegistration);
    }

    /**
     * 批量删除考生报名信息
     * 
     * @param idNumbers 需要删除的考生报名信息主键
     * @return 结果
     */
    @Override
    public int deleteGkCandidateRegistrationByIdNumbers(String[] idNumbers)
    {
        return gkCandidateRegistrationMapper.deleteGkCandidateRegistrationByIdNumbers(idNumbers);
    }

    /**
     * 删除考生报名信息信息
     * 
     * @param idNumber 考生报名信息主键
     * @return 结果
     */
    @Override
    public int deleteGkCandidateRegistrationByIdNumber(String idNumber)
    {
        return gkCandidateRegistrationMapper.deleteGkCandidateRegistrationByIdNumber(idNumber);
    }
}
